<template>
	<view class="user_type_body">
		<view class="header">
			<view class="logo-title">
				<image :src="$util.img(infos.logo)" mode="aspectFit" class="logo"></image>
				<text class="font-weight">
					请先择您的身份
				</text>
			</view>

			<text class="placeholder_font">
				根据选择为您提供精准服务
			</text>
		</view>

		<!-- 用户类型 -->
		<view class="body">
			<!-- 个人用户 -->
			<view class="body_column flex " :class="cur ==1 ?'cur':''" @click="user(1)">
				<view class="flex column ">
					<text class="body-item body-item-color">
						个人用户
					</text>
					<text class="">
						商城优惠福利享不停
					</text>
				</view>
				<view class="">
					<view class="button">
						<image v-if="cur ==1" src="../../../static/selected.png" mode="widthFix"></image>
						<image v-else src="../../../static/unselected.png" mode="widthFix"></image>
					</view>
				</view>
			</view>
			<view class="body_column flex " :class="cur ==2 ?'cur':''" @click="register(2)">
				<!-- 个人跳转 -->
				<!-- <view class="flex column " @click="redirectToLink('/pages/login/register/phone_reg')"> -->
				<!-- <view class="flex column" @click="redirectToLink('/pages/login/register/oneself_type')"> -->
				<view class="flex column" @click="">
					<text class="body-item body-item-color">
						企业用户
					</text>
					<text class="">
						各种企业福利优惠尽在商场
					</text>
				</view>
				<view class="">
					<view class="button">
						<!-- 红 -->
						<image v-if="cur == 2" src="../../../static/selected.png" mode="widthFix"></image>
						<!-- 白 -->
						<image v-else src="../../../static/unselected.png" mode="widthFix"></image>


					</view>
				</view>
			</view>
		</view>



		<button class="footer" type="" @click="redirectToLink()">下一步</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// logo图
				infos: {},
				cur: 1,
				redirect: 'redirectTo',
				back: '',
			};
		},
		onLoad(option) {
			console.log(option,'1111')
			let url = '';
			if (option.back) {
				url = decodeURIComponent(option.back);
				if(option.redirectMode){
					this.redirect = option.redirectMode;
				}
				Object.keys(option).forEach(function(key) {
					if (key != 'back') {
						if (url.indexOf('?') != -1) {
							url += '&' + key + '=' + option[key];
						} else {
							url += '?' + key + '=' + option[key];
						}
					}
				});
				this.back = url;
				console.log(this.back,'2222')
			}
		},
		onShow() {
			this.getInfo()
		},
		methods: {
			// 用户
			user(type) {
				this.cur = type

			},
			register(type) {
				this.cur = type
			},


			getInfo() {
				// 获取网站信息
				this.$api.sendRequest({
					url: '/api/website/info',
					success: res => {
						if (res.code == 0) {
							this.infos = res.data;

							// console.log('获取网站信息1' + this.infos.longitude);
							// console.log('获取网站信息2' + this.infos.latitude);
						}
					}
				});
			},
			redirectToLink() {
				if (this.cur == 1) {
					this.$util.redirectTo('/pages/login/register/phone_reg?back='+this.back);
				} else {
					this.$util.redirectTo('/pages/login/register/oneself_type?back='+this.back);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.flex {
		display: flex;
	}

	.flex.column {
		flex-direction: column;
		background: #F8F8F8;
		width: 100%;
	}

	.user_type_body {
		box-sizing: border-box;
		padding: 150rpx 50rpx;
		background-color: #FFFFFF;

		.header {
			display: flex;
			flex-direction: column;
			padding-bottom: 40rpx;

			.logo-title {
				display: flex;
				align-items: center;
			}

			.font-weight {
				font-weight: 900;
				font-size: 64rpx;
				padding-bottom: 6rpx;
			}

			.placeholder_font {
				color: #606266;
			}

			.logo {
				width: 70rpx;
				height: 70rpx;
				margin-right: 10rpx;
			}

		}


	}

	.body {
		.body_column {
			padding: 40rpx 50rpx;
			display: flex;
			justify-content: space-between;
			background-color: #f8f8f8;
			margin-bottom: 72rpx;

			&:nth-of-type(2) {
				margin-bottom: 0px;
			}

			border-radius: 10rpx;

			&.cur {
				border: 2rpx solid #FF4544;
			}
		}

		.button {
			width: 100%;
			height: 100%;
			display: flex;
			align-items: center;

			image {
				width: 57rpx;
				height: 57rpx;
			}

		}
	}

	.footer {
		box-sizing: border-box;
		background: #FF4544;
		color: #fff;
		margin-top: 400rpx;
	}
</style>
